package com.page;
import java.util.List;

/**
 * 分页工具类
 * @author GDD
 *
 */
public class Page<T> {
        private  Integer pageNo;//当前页码数
        private Integer pageSize;//每页的信息条数
        private Integer rows; //总信息条数
        private  Integer pageTotal;   //总页码数
        private  List<T> list;    //集合
        
        public Page(Integer pageNo, Integer pageSize, Integer rows) {
            
            this.pageSize = pageSize;
            this.rows = rows;
            //先算出总页码数  
            this.pageTotal=this.rows%this.pageSize == 0?this.rows/this.pageSize:(this.rows/this.pageSize)+1;
            //判断 pageNo 的几种情况
            if(pageNo == null){
                this.pageNo=1;
            }else if (pageNo<1) {
                this.pageNo=1;
            }else if (pageNo>this.pageTotal) {
                this.pageNo=this.pageTotal;
            }else {
                this.pageNo=pageNo;
            }
            
        }

        public List<T> getList() {
            return list;
        }

        public void setList(List<T> list) {
            this.list = list;
        }
        public Integer getPageNo() {
            return pageNo;
        }
        public void setPageNo(Integer pageNo) {
            this.pageNo = pageNo;
        }
        public Integer getPageSize() {
            return pageSize;
        }
        public void setPageSize(Integer pageSize) {
            this.pageSize = pageSize;
        }
        public Integer getRows() {
            return rows;
        }
        public void setRows(Integer rows) {
            this.rows = rows;
        }
        public Integer getPageTotal() {
            return pageTotal;
        }
        public void setPageTotal(Integer pageTotal) {
            this.pageTotal = pageTotal;
        }

        public String toString() {
            return "Page [pageNo=" + pageNo + ", pageSize=" + pageSize + ", rows=" + rows + ", pageTotal=" + pageTotal
                    + ", list=" + list + "]";
        }
        
}
